<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>短消息查询</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<SCRIPT type="text/javascript"
			src="<%=basePath%>javaScripts/jquery-1.5.1.min.js"></SCRIPT>
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>styles/friends_style.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>styles/tr_style.css" />
		<script type="text/javascript"
			src="<%=basePath%>javaScripts/tr_toggle.js"></script>
		<style type="text/css">
.msg_td td {
	padding-top: 2px;
	padding-bottom: 2px;
	line-height: 28px;
	border-bottom: 1px solid #cccccc;
	padding-right: 4px;
}
 
</style>

		<SCRIPT type="text/javascript">
		var xmlHttp;
        function createXMLHttpRequest() {
	    if (window.ActiveXObject) {	 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } else {
		if (window.XMLHttpRequest) {		
			xmlHttp = new XMLHttpRequest();
		}
	   }
        }
	    function sendMsgs(id) {
	              
		var url ="bbs/friend/friend_ajaxGetFriendInfo?userId="+id ;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleStateChange;
		xmlHttp.open("post", url, true);
		xmlHttp.setRequestHeader("content-type",
				"application/x-www-form-urlencoded;charset=utf-8");
		xmlHttp.send(null);

	   }

	   function handleStateChange() {
		//alert(xmlHttp.readyState);
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				// alert("The server replied with: " + xmlHttp.responseXML);
				var doc = xmlHttp.responseText;
				 var fd=document.getElementById("friends");
				 fd.innerHTML=doc;
            
			}
		}
	}
	
	
</SCRIPT>
	</head>

	<body style="padding: 0px 0px 0px 0px; margin-top: 0px;">
		<div class="fd_sc">
			<div class="fd_sc_tip">
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td align="left" class="tb_left" valign="middle">
							发送短消息
						</td>
						<td align="right" class="tb_right" valign="middle">
							&nbsp;
						</td>
					</tr>
				</table>
			</div>
			<div>
			  <form action="bbs/msg_sendMsg" method="post">
			     <div  id="fom1" style="display: none;"></div>
			     <input type="hidden" value="${sessionScope.userDto.id}" name="senderId"/>  
			     <input type="hidden" value="${sessionScope.userDto.userName}" name="senderName"/> 
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					class="msg_td">
					<tr>
						<td style="padding-left: 20px">
							发送至
						</td>
						<td>
						     <%
						     String reviceId =  request.getParameter("reviceId");
						     String reviceName=request.getParameter("reviceName");
						       if(reviceName!=null&&reviceId!=null){
						      %>
							  
							   <input type="text" name="receiver"
								style="width: 120px; height: 26px" id="receiver" value="<%=reviceName%>" readonly="readonly"/>
								<input type="hidden" name="receiverId" value="<%=reviceId %>"/>
							  <% }else{ %>
							  <input type="text" name="receiver"
								style="width: 120px; height: 26px" id="receiver" readonly="readonly">
							&nbsp;&nbsp;&nbsp;
							  
							<input type="button" value="获取好友列表"
								style="background-color: #fafbc2;color: #367115; padding-top: 4px; padding-bottom: 2px;"  onclick="sendMsgs('${sessionScope.userDto.id}');"/>
								 &nbsp;&nbsp;
								<span style="width: 100px;" id="friends"> </span>
								 <script type="text/javascript">
								  function addReceiver(select){
	                                   var  rec=document.getElementById("receiver");
	                                    var content= select.options[select.selectedIndex].text; 
	                                    rec.value=content;
	                                     
	                                     var fom1=document.getElementById("fom1");
	                                     fom1.innerHTML="<input type=\"hidden\" name=\"receiverId\" value='"+select.options[select.selectedIndex].value+"' />";
	                                   }
								 </script>
								  <%} %>
						</td>
					</tr>
					<tr>
						<td style="padding-left: 20px">
							标题
						</td>
						<td>
							<input type="text" name="title"
								style="width: 320px; height: 26px">
						</td>
					</tr>
					<tr>
						<td style="padding-left: 20px">
							内容
						</td>
						<td>
							<FCK:editor instanceName="content" width="100%" height="280px" ></FCK:editor>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="submit" value="发     送"
								style="background-color: #fafbc2; color: #367115; padding-top: 4px; padding-bottom: 2px;" />
						</td>
					</tr>
				</table>
				</form>
			</div>

		</div>
		</div>
		</div>

      <s:debug></s:debug>
	</body>
</html>
